<?php
/**
 * 描述：会员管理中心-添加证书。
 * @final
 */
final class Exec_MC_Licence_Add extends Exec_MC_Master
{   
    public function Get()
    {
        $this->MasterPage_Display(View::Fetch('mc/licence/add.tpl'));
    }

    public function Post()
    {
        #准备数据
        $data=array
        (
            'Account'=>Account::Session('Username'),
            'Name'=>Functions::FormArgs('Name'),
            'Authority'=>Functions::FormArgs('Authority'),
            'PicturePath'=>Functions::FormArgs('PicturePath')
        );

        #数据验证
        //服务端数据验证

        #上传图片
        $result=Upload::Probe($_FILES['PicturePath'],Config::UPLOAD_ATTACHMENT_SIZE_IMAGE,Config::UPLOAD_ATTACHMENT_EXT_IMAGE,Config::PATH_UPLOAD_ATTACHMENT_TEMP);
        if($result['error']!=UPLOAD_ERR_NO_FILE)
        {
            if($result['error']==UPLOAD_ERR_OK)
            {
                $data['PicturePath']=Upload::Execute($_FILES['PicturePath'],Config::PATH_UPLOAD_ATTACHMENT_TEMP);
            }
            else
            {
                if($result['error']==Upload::UPLOAD_ERR_CUSTOM_EXT)
                {
                    echo 'Picture_Ext:'.Config::UPLOAD_ATTACHMENT_EXT_IMAGE;
                    return;
                }
                else if($result['error']==Upload::UPLOAD_ERR_CUSTOM_SIZE)
                {
                    echo 'Picture_Size:'.Functions::SizeFormat(Config::UPLOAD_ATTACHMENT_SIZE_IMAGE);
                    return;
                }
                else
                {
                    echo 'Picture';
                    return;
                }
            }
        }

        #插入数据
        DB::Insert('licence',$data);
        echo 'Success';
    }
}
?>